#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:pengfeifu
@file: day_10_car.py 
@version:
@time: 2021/11/10 
@email:1324734112@qq.com
@desc： 选车牌，随机从20个车牌号里，选出车牌，不能超过3个
@function：常用函数
string.digits获取数字
"""
import random
import string


def get_car_codes():
    arr = "京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽赣粤青藏川宁琼"
    car_codes = []
    for i in range(20):
        first_charset = random.choice(arr)
        second_num = random.choice(string.ascii_uppercase)
        else_nums = "".join(random.sample(string.digits + string.ascii_uppercase, 5))
        car_codes.append(first_charset + second_num + "·" + else_nums)
    return car_codes


if __name__ == "__main__":
    car_codes_choose = []
    counter = 0
    while counter < 3:
        codes = get_car_codes()
        line_wrap = 0
        for code in codes:
            line_wrap += 1
            print(code, end="\t")
            if line_wrap % 5 == 0:
                print("")
        nums = input("\n输入你选中的号码,最多选择三次哦,输入exit推出\n")
        if nums == "exit":
            break
        elif codes.count(nums) == 0:
            print("输入有误，请重新输入")
        else:
            car_codes_choose.append(nums)
            counter += 1
    print("最后你的选择是：", car_codes_choose)
